﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Main.aspx.cs" Inherits="jnxc.Web.Main" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Expires" content="0" />  
<meta http-equiv="Cache-Control" content="no-cache" />  
<meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>林业有害生物防治信息管理平台</title>
    <script src="Script/easyui/jquery.min.js"></script>
    <script src="Script/easyui/jquery.easyui.min.js"></script>
    <script src="Script/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="Script/changeEasyUITheme.js"></script>
    <link id="easyuiTheme" href="/Script/easyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="Script/easyui/themes/icon.css" rel="stylesheet" />
    <%--<script src="Script/menu.js"></script>--%>
    <script src="Script/main.js"></script>
    <link href="CSS/default.css" rel="stylesheet" />
    <link href="CSS/list.css" rel="stylesheet" />
    <link href="CSS/IconExtension.css" rel="stylesheet" />
    <script type="text/javascript">  
        var _menus = '';        
        var theme;
        var myzu = "";
        var pturl = "http://223.99.163.178:8396";        
        Date.prototype.pattern = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1, //月份        
                "d+": this.getDate(), //日        
                "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时        
                "H+": this.getHours(), //小时        
                "m+": this.getMinutes(), //分        
                "s+": this.getSeconds(), //秒        
                "q+": Math.floor((this.getMonth() + 3) / 3), //季度        
                "S": this.getMilliseconds() //毫秒        
            };
            var week = {
                "0": "/u65e5",
                "1": "/u4e00",
                "2": "/u4e8c",
                "3": "/u4e09",
                "4": "/u56db",
                "5": "/u4e94",
                "6": "/u516d"
            };
            if (/(y+)/.test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            }
            if (/(E+)/.test(fmt)) {
                fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""]);
            }
            for (var k in o) {
                if (new RegExp("(" + k + ")").test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                }
            }
            return fmt;
        }
        var Common = {

            //EasyUI用DataGrid用日期格式化
            TimeFormatter: function (value, rec, index) {
                if (value == undefined) {
                    return "";
                }
                /*json格式时间转js时间格式*/
                value = value.substr(1, value.length - 2);
                var obj = eval('(' + "{Date: new " + value + "}" + ')');
                var dateValue = obj["Date"];
                if (dateValue.getFullYear() < 1900) {
                    return "";
                }
                var val = dateValue.pattern("yyyy-MM-dd HH:mm");
                return val;
            },
            DateTimeFormatter: function (value, rec, index) {

                if (value == null || value == '') {
                    return '';
                }
                var dt;
                if (value instanceof Date) {
                    dt = value;
                }
                else {
                    dt = new Date(value);
                    if (isNaN(dt)) {
                        value = value.replace(/\/Date\((-?\d+)\)\//, '$1'); //标红的这段是关键代码，将那个长字符串的日期值转换成正常的JS日期格式
                        dt = new Date();
                        dt.setTime(value);
                    }
                }
                return dt.pattern("yyyy年M月d日");
            },

            //EasyUI用DataGrid用日期格式化
            DateFormatter: function (value, rec, index) {
                if (value == undefined) {
                    return "";
                }
                /*json格式时间转js时间格式*/
                value = value.substr(1, value.length - 2);
                var obj = eval('(' + "{Date: new " + value + "}" + ')');
                var dateValue = obj["Date"];
                if (dateValue.getFullYear() < 1900) {
                    return "";
                }

                return dateValue.pattern("yyyy-MM-dd");
            }
        };
        function InitGird() {
            $('#tt').datagrid({
                title: '发布信息列表(' + myzu + ")", //表格标题
                url: '../info/GetInfo.ashx', //请求数据的页面
                sortName: 'infotime', //排序字段
                idField: 'iid', //标识字段,主键
                iconCls: '', //标题左边的图标
                //width: '100%', //宽度
                height: 250,// $(parent.document).find("#mainPanle").height() - 50 > 0 ? $(parent.document).find("#mainPanle").height() - 80 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                method: 'post',
                columns: [[
	                { title: '标题', field: 'title', width: 150 },
                    {
                        title: '发布时间', field: 'infotime', width: 150, formatter: function (value, row, index) {
                            if (value != "") {
                                if (value.indexOf("-") != -1)
                                    value = value.replace(/-/g, "/");
                                return new Date(value).pattern("yyyy年M月d日");
                            }
                        }
                    },
                    { title: '发布人', field: 'uname', width: 150 },
                    { title: '发布群组', field: 'caname', width: 150 },
                    {
                        title: '操作', field: 'iid', width: 80, formatter: function (value, row, index) {

                            return '<a style="color:red" href="javascript:" onclick="$(this).parent().click();showData(' + value + ');return false;">详细信息</a>';
                        }
                    }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "top" },
                pagination: false, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });


        }
        function showData(value) {
            //清空内容            
            //$('#dlg').dialog('open').dialog('setTitle', '信息');
            var row = $('#tt').datagrid('getSelected');
            if (row == null) {
                $.messager.alert("提示", "请选择要显示的行！", "info");
            }
            if (row) {
                $('#dlgmsg').dialog('open').dialog('setTitle', '详细信息');
                $("#caname").text(row.caname);
                $("#stitle").text(row.title);
                $("#suname").text(row.uname);
                var result = $.ajax({
                    url: "../info/GetInfo.ashx?action=getinfo&iid=" + row.iid,
                    type: 'post',
                    dataType: 'json',
                    async: false,
                    cache: false
                }).responseText;
                //$("#psinfo").html(result);
                $('#infocontent').html(result);
            }
        }
        function getLevelname(level) {
            var lname="";
            if (level == "0")
                lname = "普通用户";
            else if (level == "1")
                lname = "县级用户";
            else if (level == "2")
                lname = "市级用户";
            else if (level == "3")
                lname = "省级用户";
            else if (level == "4")
                lname = "全国用户";
            else if (level == "5")
                lname = "管理员";
            return lname;

        }
        $(function () {
            $("#editpass").click(function () {
                $('#w').window('open');
            });
            $('#btnEp').click(function () {
                serverLogin();
            });

            $('#btnCancel').click(function () {
                closePwd();
            })
            $.ajax({
                url: "ashx/SysMenu.ashx?Method=GetMenuByUserID",
                dataType: 'text',
                type: "post",
                success: function (returnData) {
                    _menus = eval('(' + returnData + ')');
                    InitLeftMenu();
                }
            });
            $.ajax({
                type: "post",
                dataType: "json",
                url: "admin/getinfo.ashx?action=level",
                success: function aa(data) {
                    var level = data[0].level;
                    var name = data[0].name;
                    var uadd = data[0].province + data[0].city + data[0].county + data[0].uadd;
                    $("#myinfos").text("用户名：" + name + " 地址：" + uadd + " 用户权限:" + getLevelname(level));
                   
                }
            });
            var result = $.ajax({
                url: "../admin/getinfo.ashx?action=myzu",
                type: 'post',
                dataType: 'json',
                async: false,
                cache: false
            }).responseText;
            //$("#psinfo").html(result);
            myzu = result;
            InitGird();
            tabClose();
            tabCloseEven();
            openPwd();
            $("#info").window("close");            
            if ($.cookie('easyuiThemeName')) {
                changeThemeFun($.cookie('easyuiThemeName'));
                theme = $.cookie('easyuiThemeName');
            }            
            $('#loginOut').click(function () {
                $.messager.confirm('系统提示', '您确定要退出本次登录吗?', function (r) {
                    if (r) {
                        location.href = 'loginout.aspx';
                    }
                });
            });
            $('#myinfo').click(function () {
                $.ajax({
                    type: "post",
                    dataType: "json",
                    url: "userinfo/GetUser.ashx?action=myinfo",
                    success: function aa(data) {
                        $("#uname").text(data.rows[0].uname);
                        $("#uprovince").text(data.rows[0].uprovince + data.rows[0].ucity + data.rows[0].ucounty);
                        $("#uunit").text(data.rows[0].uunit);
                        $("#utruename").val(data.rows[0].utruename);
                        $("#uphone").val(data.rows[0].uphone);
                        $("#uemail").val(data.rows[0].uemail);
                        $("#utel").val(data.rows[0].utel);
                        $("#uadd").val(data.rows[0].uadd);
                    }
                });
                $('#dlg').dialog('open').dialog('setTitle', '个人信息');



            });
            getPT();

        });
        function saveUser() {            
                $('#fm').form('submit', {
                    url: "userinfo/GetUser.ashx?action=updatemyinfo",
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        if (result.indexOf("T") == 0) {
                            $('#dlg').dialog('close');                            
                            $.messager.alert("提示", "恭喜您，信息修改成功", "info");
                        }
                        else if ((result.indexOf("F") == 0)) {
                            $.messager.alert("提示", "修改失败，请重新操作！", "info");
                            return;
                        }
                        else if ((result.indexOf("L") == 0)) {
                            $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                            top.location = '/index.aspx';
                            return;
                        }
                    }
                });           
        }
        function getPT()
        {
            var uid=<%=uid%>;
            //var uid = 54;
            $.ajax({
                type: "post",
                dataType: "json",
                url: pturl+"/CheckUser.ashx?type=fz&uid="+uid,
                success: function aa(data) {
                    if (data[0].fz != "") {
                        $("#mfz").attr("href", "http://223.99.163.178:126" + "/LoginService.aspx?loginId=" + data[0].fz);
                    }
                    else {
                        $("#mfz").hide();
                    }
                    if (data[0].cb != "") {
                        $("#mcb").attr("href", "http://223.99.163.178:8081" + "/LoginService.aspx?loginId=" + data[0].cb);
                    }
                    else {
                        $("#mcb").hide();
                    }
                    if (data[0].sb != "") {
                        $("#msb").attr("href", "http://223.99.163.178:98" + "/LoginService.aspx?loginId=" + data[0].sb);
                    }
                    else {
                        $("#msb").hide();
                    }
                    $("#mfz").hide();
                }
            });

        }
    </script>
</head>
<body class="easyui-layout" style="overflow-y: hidden" scroll="no">
    <noscript>
        <div style="position: absolute; z-index: 100000; height: 2046px; top: 0px; left: 0px; width: 100%; background: white; text-align: center;">
            <img src="images/noscript.gif" alt='抱歉，请开启脚本支持！' />
        </div>
    </noscript>
    <div region="north"  border="false" style="overflow: hidden; height: 73px; background: url(images/top.jpg) #7f99be no-repeat; line-height: 20px; background-color:#336fad; color: #fff; font-family: Verdana, 微软雅黑,黑体">
       
        <span style="float: right; text-align:right; padding-right: 20px; margin-top:15px;" class="head"><a href="#" id="mb" class="easyui-menubutton" data-options="menu:'#menu',iconCls:'icon-ok'">换肤</a>
            <a href="http://223.99.163.178:8396" target="_blank" id="mpt" >统一平台</a>

            <a href="http://223.99.163.178:126" target="_blank" id="mfz"  >防治平台</a>
            <a href="http://223.99.163.178:8081/index.aspx" target="_blank" id="mcb"  >测报平台</a>
            <a href="http://223.99.163.178:98/login.html" target="_blank" id="msb" >设备监测平台</a>
             <a href="/ecshop/index.aspx" target="_blank" >有害生物药品药械防治平台</a> 
             <a href="#" id="myinfo" >个人信息</a> <a href="#" id="editpass">修改密码</a> <a href="#" id="loginOut">安全退出</a><br />欢迎 <span id="myinfos"></span></span>
        
      
    &nbsp;</div>
    <div region="south" style="height: 30px; background: #D2E0F2;">
        <div class="footer">济南祥辰科技有限公司</div>
    </div>
    <div region="west" split="true" title="导航菜单" style="width: 180px;" id="west">
        <div class="easyui-accordion1" fit="true" border="false">
            <!--  导航内容 -->



        </div>

    </div>
    <div id="mainPanle" region="center" style="background: #eee; overflow-y: hidden">
        <div id="tabs" class="easyui-tabs" fit="true" >
            <div title="欢迎使用" style="padding:5px; overflow: hidden;" id="home">

                <table id="tt">
    </table>
            </div>
        </div>
    </div>
    <div id="w" class="easyui-window" title="修改密码" collapsible="false" minimizable="false"
        maximizable="false" icon="icon-save" style="width: 300px; height: 150px; padding: 5px; background: #fafafa;">
        <div class="easyui-layout" fit="true">
            <div region="center" border="false" style="padding: 10px; background: #fff; border: 1px solid #ccc;">
                <table cellpadding="3">
                    <tr>
                        <td>
                            旧密码：
                        </td>
                        <td>
                            <input id="OldPassword" name="OldPassword" type="Password" class="easyui-validatebox" required="true" />
                        </td>
                    </tr>

                    <tr>
                        <td>新密码：</td>
                        <td>
                            <input id="NewPassword" type="Password" class="txt01" /></td>
                    </tr>
                    <tr>
                        <td>确认密码：</td>
                        <td>
                            <input id="txtRePass" type="Password" class="txt01" /></td>
                    </tr>
                </table>
            </div>
            <div region="south" border="false" style="text-align: right; height: 40px; line-height: 30px;">
                <a id="btnEp" class="easyui-linkbutton" icon="icon-ok" href="javascript:void(0)">确定</a> <a id="btnCancel" class="easyui-linkbutton" icon="icon-cancel" href="javascript:void(0)">取消</a>
            </div>
        </div>
    </div>
    <div id="menu" class="easyui-menu" style="width:120px;">
         <div onclick="changeThemeFun('default')" >Default</div>
           <div onclick="changeThemeFun('gray')" >Gray</div>
            <div onclick="changeThemeFun('black')" >Black</div>
        <div onclick="changeThemeFun('bootstrap')" >bootstrap</div>        
        <div onclick="changeThemeFun('metro')" >metro</div>
        <div onclick="changeThemeFun('metro-blue')" >metro-blue</div>
        <div onclick="changeThemeFun('metro-gray')" >metro-gray</div>
        <div onclick="changeThemeFun('metro-green')" >metro-green</div>
        <div onclick="changeThemeFun('metro-orange')" >metro-orange</div>
        <div onclick="changeThemeFun('metro-red')" >metro-red</div>
        <div onclick="changeThemeFun('ui-cupertino')" >ui-cupertino</div>
        <div onclick="changeThemeFun('ui-dark-hive')" >ui-dark-hive</div>
        <div onclick="changeThemeFun('ui-pepper-grinder')" >ui-pepper-grinder</div>
        <div onclick="changeThemeFun('ui-sunny')" >ui-sunny</div>
                 
        </div>
    <div id="mm" class="easyui-menu" style="width: 150px;">
        <div id="mm-tabclose">关闭</div>
        <div id="mm-tabcloseall">全部关闭</div>
        <div id="mm-tabcloseother">除此之外全部关闭</div>
        <div class="menu-sep"></div>
        <div id="mm-tabcloseright">当前页右侧全部关闭</div>
        <div id="mm-tabcloseleft">当前页左侧全部关闭</div>
        <div class="menu-sep"></div>
        <div id="mm-exit">退出</div>
    </div>
     <div id="dlg" class="easyui-dialog" style="width: 400px; height: auto; padding: 10px 20px"
            data-options="closed:true,buttons:'#dlg-buttons',shadow:false">

                        <form id="fm" method="post">

                <div class="fitem">
                    <label>用户名：</label>
                    <span id="uname"  ></span>
                </div>
                             <div class="fitem" id="dprovince">
                    <label>地区：</label>
                    <span id="uprovince" ></span>
                </div>               
                <div class="fitem">
                    <label>单位：</label>
                    <span id="uunit"  ></span>
                </div>                            
                <div class="fitem">
                    <label>负责人姓名：</label>
                    <input id="utruename" name="utruename" class="easyui-validatebox" data-options="required:true" />
                </div>
                <div class="fitem">
                    <label>手机：</label>
                    <input id="uphone" name="uphone" class="easyui-validatebox" data-options="required:true" />
                </div>
                <div class="fitem">
                    <label>邮箱：</label>
                    <input id="uemail" name="uemail" class="easyui-validatebox" data-options="required:true,validType:'email'" />
                </div>
                
                <div class="fitem">
                    <label>单位电话：</label>
                    <input id="utel" name="utel" class="easyui-validatebox" data-options="required:true" />
                </div>                
               
                <div class="fitem">
                    <label>地址：</label>
                    <input id="uadd" name="uadd" class="easyui-validatebox" />
                </div>                
            </form>

        </div>
        <div id="dlg-buttons">
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="saveUser()">保存</a>
            <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlg').dialog('close')">关闭</a>
        </div>
     <div id="dlgmsg" class="easyui-dialog" style="width: 850px; height: auto; padding: 10px 20px"
        data-options="closed:true,buttons:'#Div2',shadow:false,top:50">
        <form id="Form1" method="post" >
            <div class="fitem">
                <label>群组名：</label>
                <span id="caname"></span>
                </div>
            <div class="fitem">
                <label>标题：</label>
                <span id="stitle" ></span>
            </div> 
            <div class="fitem">
                <label>作者：</label>
                <span id="suname" ></span>
            </div>           
            <div >
                <label>内容：</label>
                
                <span  id="infocontent"  ></span>               
                <input name="iid" id="iid" type="hidden" />                   
                <input id="key" name="key" onkeydown="if(event.keyCode==13)reloadgrid()" type="hidden" />                
            </div>
            <div>                         
                </div>
        </form>
    </div>
    <div id="Div2">        
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="javascript:$('#dlgmsg').dialog('close')">关闭</a>
    </div>
   
</body>
</html>
